package com.jarvis.hospital.patient.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jarvis.hospital.R;
import com.jarvis.hospital.patient.model.MessageModel;
import com.jarvis.hospital.prescription.model.PrescriptionTimeDetailModel;

import java.util.List;

/**
 * Created by jarvis.liu on 9/12/2016.
 */
public class MessageDetailAdapter extends BaseQuickAdapter<MessageModel> {
    public MessageDetailAdapter(int layoutResId, List<MessageModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, MessageModel messageModel) {
        TextView tv_index = baseViewHolder.getView(R.id.tv_index);
        RelativeLayout rel_left = baseViewHolder.getView(R.id.rel_left);
        ImageView iv_avatar = baseViewHolder.getView(R.id.iv_avatar);
        TextView tv_name = baseViewHolder.getView(R.id.tv_name);

        RelativeLayout rel_right = baseViewHolder.getView(R.id.rel_right);
        ImageView img_right = baseViewHolder.getView(R.id.img_right);
        TextView tv_right = baseViewHolder.getView(R.id.tv_right);
        tv_index.setText(messageModel.getSendTime());
        if("B".equals(messageModel.getType())){
            rel_left.setVisibility(View.VISIBLE);
            rel_right.setVisibility(View.GONE);
            tv_name.setText(messageModel.getMsgContent());
            Glide.with(mContext)
                    .load(messageModel.getReceiverHeadImg())
                    .error(R.mipmap.ic_launcher)
                    .into(iv_avatar);
        }else {
            rel_left.setVisibility(View.GONE);
            rel_right.setVisibility(View.VISIBLE);
            tv_right.setText(messageModel.getMsgContent());
            Glide.with(mContext)
                    .load(messageModel.getSenderHeadImg())
                    .error(R.mipmap.ic_launcher)
                    .into(img_right);
        }

    }
}
